home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d16 / newpap12.arc / NEWPAPER.C < prev    next >
Text File  |  1990-10-27  |  3KB  |  103 lines

  1. /*
  2.  **************************************************************
  3.  * newpaper.c                                                 *
  4.  * 7/28/90 by Jim Button                                      *
  5.  *------------------------------------------------------------*
  6.  * Updates WIN.INI Wallpaper specification to point to the    *
  7.  *   to the next BMP file in the windows subdirectory.        *
  8.  *                                                            *
  9.  * This hardly looks like a Windows program. The traditional  *
  10.  *   message loop is not even needed, since it does no input, *
  11.  *   has no output, and terminates almost before it starts!   *
  12.  **************************************************************
  13.  
  14. Modified by Roger Hadgraft
  15.  
  16. 16/10/1990    Looks in Win.ini for tiling or centering.
  17.         Otherwise it asks, and records the setting.
  18.         Pressing "Cancel" causes no setting to be recorded, and
  19.         sets centering on as a means of previewing the bitmap.
  20.  */
  21.  
  22. #ifndef _WINDOWS
  23. #define _WINDOWS
  24. #endif
  25.  
  26. #include <windows.h>
  27. /* #include <types.h>
  28. #include <stat.h> */
  29. #include <dos.h>
  30. #include <string.h>
  31.  
  32. static char msg[]       = " By Jim Button ";
  33. static char WallPaper[] = "Wallpaper";
  34.  
  35. #define MAX_PROF_STR  13
  36.  
  37.  
  38. int PASCAL WinMain(  HANDLE hInstance,
  39.                      HANDLE hPrevInstance,
  40.                      LPSTR lpszCmdLine,
  41.                      int nCmdShow)
  42. {
  43.    unsigned int done;
  44.    char oldbmp[MAX_PROF_STR+1];
  45.    char firstbmp[MAX_PROF_STR+1];
  46.    char newbmp[MAX_PROF_STR+1];
  47.    struct  find_t dta;
  48. /* struct  stat   buf; */
  49.    char *tiled;
  50.    int    result;
  51.  
  52.    GetProfileString((LPSTR)"Desktop", (LPSTR)"WallPaper", (LPSTR)"", (LPSTR)oldbmp, MAX_PROF_STR);
  53.    newbmp[0] = '\0';                            /* In case no BMP files exist */
  54.  
  55.    /*** Get the list of .BMP files ***/
  56.    done = _dos_findfirst("*.BMP", 0, &dta);     /* Find files */
  57.    if (!done) {
  58.       strcpy(firstbmp, dta.name);
  59.       strcpy(newbmp, firstbmp);
  60.       }
  61.  
  62.    while (!done) {
  63.       if (!strcmpi(dta.name, oldbmp)) {         /* Current one? */
  64.           done = _dos_findnext(&dta);
  65.           strcpy(newbmp, (done ? firstbmp : dta.name));
  66.           break;
  67.           }
  68.       done = _dos_findnext(&dta);
  69.       }
  70.  
  71.    /*** Update WIN.INI ***/
  72.    WriteProfileString((LPSTR)"Desktop", (LPSTR)"WallPaper", (LPSTR)newbmp);
  73.  
  74.    /*** Check for a previously recorded setting, otherwise ask ***/
  75.    result = GetProfileInt("Desktop", newbmp, -1);
  76.    if( result == -1 ) {
  77.     /* this bitmap hasn't been specified yet */
  78.     result = MessageBox( GetActiveWindow(), (LPSTR)"Tile this BitMap on the DeskTop ?\n(Otherwise centre it)",
  79.         (LPSTR)newbmp, MB_ICONQUESTION | MB_YESNOCANCEL );
  80.     if( result == IDYES )
  81.         tiled = "1";                         /* Point to string "1" */
  82.     else
  83.         tiled = "0";
  84.     if( result != IDCANCEL )
  85.         /* record choice as a permanent setting */
  86.         WriteProfileString((LPSTR)"Desktop", (LPSTR)newbmp, (LPSTR)tiled);
  87.     }
  88.  
  89.     else {
  90.     if( result == 1 )
  91.         tiled = "1";                         /* Point to string "1" */
  92.     else
  93.         tiled = "0";
  94.     }
  95.  
  96.    WriteProfileString((LPSTR)"Desktop", (LPSTR)"TileWallpaper", (LPSTR)tiled);
  97.  
  98.    return(FALSE);
  99. }
  100.  
  101.  
  102.  
  103.